﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Satates.FarmerStates;

namespace Operators.FarmerOperators
{
    public class MoveFarmerRight:iOperator
    {
        public FarmerStates execute(FarmerStates s)
        {
            FarmerStates s2 = new FarmerStates(s);
            s2.setLeftFarmer(0);
            s2.setRightFarmer(1);
            return s2;
        }

        public bool available(FarmerStates s)
        {
            if (s.getLeftFarmer() == 1)
            {
                if (!(s.getLeftWolf() == 1 && s.getLeftSheep() == 1))
                {
                    if (!(s.getLeftCabbage() == 1 && s.getLeftSheep() == 1))
                    {
                        return true;
                    }
                }
            }
            return false;

        }


        public override string ToString()
        {
            return "Moving Farmer Right";
        }
        public int getOperatorNumber()
        {
            return 7;
        }

        public Common.Template execute(Common.Template t)
        {
            FarmerStates s2 = (FarmerStates)t;
            s2.setLeftFarmer(0);
            s2.setRightFarmer(1);
            return s2;
        }

        public bool available(Common.Template t)
        {
            FarmerStates s = (FarmerStates)t;
            if (s.getLeftFarmer() == 1)
            {
                if (!(s.getLeftWolf() == 1 && s.getLeftSheep() == 1))
                {
                    if (!(s.getLeftCabbage() == 1 && s.getLeftSheep() == 1))
                    {
                        return true;
                    }
                }
            }
            return false;
        }
        public object Clone()
        {
            return this.MemberwiseClone();
        }
    }
}
